package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiFacadeDocDao;
import com.cw.jeeyt.dao.mapper.api.ApiFacadeDocMapper;
import com.cw.jeeyt.dao.model.api.ApiFacadeDocDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * api接口文档 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiFacadeDocDaoImpl implements ApiFacadeDocDao {
    @Autowired
    private ApiFacadeDocMapper apiFacadeDocMapper;

    /**
     * 新增api接口文档
     *
     * @param apiFacadeDoc
     * @return 整数
     */
    public Integer insert(ApiFacadeDocDo apiFacadeDoc) {
        return apiFacadeDocMapper.insert(apiFacadeDoc);
    }

    /**
     * 新增api接口文档不为空的字段
     *
     * @param apiFacadeDoc
     * @return 整数
     */
    public Integer insertSelective(ApiFacadeDocDo apiFacadeDoc) {
        return apiFacadeDocMapper.insertSelective(apiFacadeDoc);
    }

    /**
     * 删除api接口文档
     *
     * @param apiFacadeDoc
     */
    public void delete(ApiFacadeDocDo apiFacadeDoc) {
        apiFacadeDocMapper.delete(apiFacadeDoc);
    }

    /**
     * 修改api接口文档不为null的字段
     *
     * @param apiFacadeDoc
     */
    public void updateSelective(ApiFacadeDocDo apiFacadeDoc) {
        apiFacadeDocMapper.updateSelective(apiFacadeDoc);
    }

    /**
     * 修改api接口文档
     *
     * @param apiFacadeDoc
     */
    public void update(ApiFacadeDocDo apiFacadeDoc) {
        apiFacadeDocMapper.update(apiFacadeDoc);
    }

    /**
     * 根据主键查询api接口文档
     *
     * @return api接口文档
     */
    public ApiFacadeDocDo getById(Long id) {
        return apiFacadeDocMapper.getById(id);
    }

    /**
     * 查询所有api接口文档
     *
     * @return api接口文档集合
     */
    public List<ApiFacadeDocDo> queryApiFacadeDocList() {
        return apiFacadeDocMapper.queryApiFacadeDocList();
    }

    /**
     * 分页查询api接口文档
     *
     * @param apiFacadeDoc 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return api接口文档集合
     */
    public PageInfo<ApiFacadeDocDo> queryByPage(ApiFacadeDocDo apiFacadeDoc, Integer startRow, Integer pageSize,
        Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiFacadeDocMapper.queryByPage(apiFacadeDoc, order));
    }

    /**
     * 查询api接口文档
     *
     * @param requestData
     * @return
     * @throws Exception
     */
    public List<ApiFacadeDocDo> searchResult(String requestData) {
        return apiFacadeDocMapper.searchResult(requestData);
    }

    /**
     * 根据接口文档编码查询接口文档信息
     *
     * @param apiDocCode
     * @return
     * @throws Exception
     */
    public ApiFacadeDocDo getApiFacadeDocByDocCode(String apiDocCode) {
        return apiFacadeDocMapper.getApiFacadeDocByDocCode(apiDocCode);
    }

    /**
     * 批量保存接口文档信息
     *
     * @param apiDocList
     * @throws Exception
     */
    public void insertBat(List<ApiFacadeDocDo> apiDocList) {
        apiFacadeDocMapper.insertBat(apiDocList);
    }

    /**
     * 根据项目编码查询项目下的所有接口信息
     *
     * @param projectCode
     * @return
     */
    public List<ApiFacadeDocDo> queryListByProjectCode(String projectCode) {
        return apiFacadeDocMapper.queryListByProjectCode(projectCode);
    }

}
